package
{
	import flash.display.Sprite;
	
	public class StageRelation extends Sprite
	{
		public function StageRelation()
		{
			function fen():void
			{
				trace("-----------------------------------------------------------");
			}
			
			trace("this就是" + this);
			trace("this.name就是" + this.name);
			trace("root就是" + root);
			trace("root.name就是" + root.name);
			trace("parent就是" + parent);
			trace("parent.name就是" + parent.name);
			trace("stage就是" + stage);
			trace("stage.name就是" + stage.name);
			fen();
			trace("numChildren就是" + numChildren);
			trace("this.numChildren就是" + this.numChildren);
			trace("stage.numChildren就是" + stage.numChildren);
			trace("parent.numChildren就是" + parent.numChildren);
			fen();
			trace("stage.getChildIndex(this)就是" + stage.getChildIndex(this))
			trace("stage.getChildIndex(root)就是" + stage.getChildIndex(root))
			trace("stage.getChildAt(0)就是" + stage.getChildAt(0));
			trace("stage.getChildAt(0).name就是" + stage.getChildAt(0).name);
			trace("stage.getChildByName(\"root1\")就是" + stage.getChildByName("root1"));
			
			trace("parent.getChildIndex(this)就是" + parent.getChildIndex(this))
			trace("parent.getChildIndex(root)就是" + parent.getChildIndex(root))
			trace("parent.getChildAt(0)就是" + parent.getChildAt(0));
			trace("parent.getChildAt(0).name就是" + parent.getChildAt(0).name);
			trace("parent.getChildByName(\"root1\")就是" + parent.getChildByName("root1"));
			fen();
			
			trace("修改root.name或者this.name的结果:Error #2078: 无法修改位于时间轴上的对象的名称属性。");
			
			var a:Sprite = new Sprite();
			a.graphics.beginFill(0x000000);
			a.graphics.drawRect(100,100,100,100);
			a.graphics.endFill();
			a.name="a";
			addChild(a);
			trace("addChild(a)");
			trace("getChildIndex(a)就是" + getChildIndex(a));
			trace("this.getChildIndex(a)就是" + this.getChildIndex(a));
			trace("this.getChildAt(0)就是" + this.getChildAt(0));
			trace("this.getChildAt(0).name就是" + this.getChildAt(0).name);
			trace("this.getChildByName(\"a\")就是" + this.getChildByName("a"));
			trace("root.getChildIndex(a)的结果:1061: 调用可能未定义的方法 getChildIndex (通过 static 类型 flash.display:DisplayObject 引用)。");
			trace("root.getChildAt(0)的结果:1061: 调用可能未定义的方法 getChildAt (通过 static 类型 flash.display:DisplayObject 引用)。");
			trace("stage.getChildIndex(a)的结果:Error #2025: 提供的 DisplayObject 必须是调用者的子级。");
			trace("parent.getChildIndex(a)的结果:Error #2025: 提供的 DisplayObject 必须是调用者的子级。");
			trace("this.numChildren就是" + this.numChildren);
			trace("stage.numChildren就是" + stage.numChildren);
			trace("parent.numChildren就是" + parent.numChildren);
			fen();
			this.addChild(a);
			trace("this.addChild(a)");
			trace("this.getChildIndex(a)就是" + this.getChildIndex(a));
			trace("this.getChildAt(0)就是" + this.getChildAt(0));
			trace("this.getChildAt(0).name就是" + this.getChildAt(0).name);
			trace("this.getChildByName(\"a\")就是" + this.getChildByName("a"));
			fen();
			stage.addChild(a);
			trace("stage.addChild(a)");
			trace("stage.getChildIndex(a)就是" + stage.getChildIndex(a));
			trace("numChildren就是" + numChildren);
			trace("this.numChildren就是" + this.numChildren);
			trace("stage.numChildren就是" + stage.numChildren);
			trace("parent.numChildren就是" + parent.numChildren);
			trace("stage.getChildAt(0)就是" + stage.getChildAt(0));
			trace("stage.getChildAt(1)就是" + stage.getChildAt(1));
			trace(stage.setChildIndex(a,0));
			trace("在stage.setChildIndex(a,0)之后");
			trace("stage.getChildAt(0)就是" + stage.getChildAt(0));
			trace("stage.getChildAt(1)就是" + stage.getChildAt(1));
			trace("stage.getChildAt(0).name就是" + stage.getChildAt(0).name);
			trace("stage.getChildByName(\"a\")就是" + stage.getChildByName("a"));
			fen();
			var b:Sprite = new Sprite();
			b.name = "b";
			parent.addChild(b);
			b.graphics.beginFill(0xffff00);
			b.graphics.drawRect(75,125,50,50);
			b.graphics.endFill();
			trace("在parent.addChild(b)之后");
			trace("stage.getChildAt(0)就是" + stage.getChildAt(0));
			trace("stage.getChildAt(1)就是" + stage.getChildAt(1));
			trace("stage.getChildAt(0)就是" + stage.getChildAt(2));
			trace("stage.getChildAt(0).name就是" + stage.getChildAt(0).name);
			trace("stage.getChildAt(1).name就是" + stage.getChildAt(1).name);
			trace("stage.getChildAt(0).name就是" + stage.getChildAt(2).name);
			fen();
			var c:Sprite = new Sprite();
			c.name = "c";
			c.graphics.beginFill(0x00ffff);
			c.graphics.drawRect(50,50,100,100);
			c.graphics.endFill();
			this.addChild(c);
			trace("numChildren就是" + numChildren);
			trace("this.numChildren就是" + this.numChildren);
			trace("stage.numChildren就是" + stage.numChildren);
			trace("parent.numChildren就是" + parent.numChildren);
			trace("this.getChildAt(0)就是" + this.getChildAt(0));
			trace("stage.getChildAt(0)就是" + stage.getChildAt(0));
			trace("stage.getChildAt(1)就是" + stage.getChildAt(1));
			trace("stage.getChildAt(0)就是" + stage.getChildAt(2));
			trace("this.getChildAt(0).name就是" + this.getChildAt(0).name);
			trace("stage.getChildAt(0).name就是" + stage.getChildAt(0).name);
			trace("stage.getChildAt(1).name就是" + stage.getChildAt(1).name);
			trace("stage.getChildAt(0).name就是" + stage.getChildAt(2).name);
			fen();
			graphics.beginFill(0xff00ff)
			graphics.drawRect(100,100,75,75);
			graphics.endFill();
			trace("显示层的不同");
			trace("黑色是a");
			trace("黄色是b");
			trace("蓝色是c");
			trace("紫色是直接graphics的效果");
		}
	}
}